package com.yxh.www.author.dto;

import com.yxh.www.author.domain.SmUser;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.List;
import java.util.Set;

/**
 * <p>
 *  用户登录 信息   Token
 * </p>
 *
 * @author yangxiaohui
 * @since 2020/5/12
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class SmUserToken implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * Token
     */
    private String token;
    /**
     * 用户权限标识
     */
    private Set<String> permissions;
    /**
     * 用户权限资源树
     */
    private List<SmResourceTree> smResource;
    /**
     * PK
     */
    private String userId;
    /**
     * 用户名
     */
    private String userName;

    /**
     * 手机号码
     */
    private String userPhone;

    /**
     * 用户头像
     */
    private String userPhoto;

    /**
     * 用户邮箱
     */
    private String userMail;


    public SmUserToken() {
    }

    public SmUserToken(String token, Set<String> permissions, SmUser smUser, List<SmResourceTree> smResource) {
        this.token = token;
        this.permissions = permissions;
        this.smResource = smResource;
        // 构建用户基本信息
        this.userId=smUser.getId();
        this.userName=smUser.getUserName();
        this.userPhone=smUser.getUserPhone();
        this.userPhoto=smUser.getUserPhoto();
        this.userMail=smUser.getUserMail();
    }
}
